﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.Master" AutoEventWireup="true" CodeBehind="frm_Periodo.aspx.cs" Inherits="ED_Nivelacion.PresentacionWeb.frm_Periodo" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .auto-style2
        {
            width: 266px;
            height: 38px;
        }
        .auto-style4
        {
            width: 266px;
            height: 53px;
        }
        .auto-style5
        {
            height: 53px;
            width: 333px;
        }
        .auto-style15
        {
            width: 333px;
        }
        </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <form id="Form1" runat="server">

        <script>
            function show() {
                document.write("<head id='head2' runat='server'></head>");
            }
</script>

        <script>
           

             $(document).ready(function () {
                

                 $(document).on("click", ".borrar", function () {

                     var id = $(this).data("id");
                     alert(id);
                     $('#ContentPlaceHolder1_idEliminar').val(id);

                 });


                 $(document).on("click", ".editar", function () {
                    var fecha1= $('#ContentPlaceHolder1_txt_FechaIn').val();
                    var fecha2= $('#ContentPlaceHolder1_txt_FechaFi').val();

                    if (fecha1 > fecha2) {
                        alert("Error");
                    }
                    else {


                        var nombre = $(this).data("nombre");
                        var fechain = $(this).data("fechain");
                        var fechafin = $(this).data("fechafin");
                        var id = $(this).data("id");

                        //alert(fechain);

                        var fecchain = $.datepicker.parseDate('dd/mm/yy', fechain);
                        var datestrInNewFormat = $.datepicker.formatDate("yy-mm-dd", fecchain);

                        var fecchafin = $.datepicker.parseDate('dd/mm/yy', fechafin);
                        var a = $.datepicker.formatDate("yy-mm-dd", fecchafin);

                        // alert(datestrInNewFormat);
                        $('#ContentPlaceHolder1_txt_NombrePeriodo').val(nombre);
                        $('#ContentPlaceHolder1_txt_FechaIn').val(datestrInNewFormat);
                        $('#ContentPlaceHolder1_txt_FechaFi').val(a);
                        $('#ContentPlaceHolder1_txt_Editar').val(id);
                        $('#ContentPlaceHolder1_Btn_Modificar_Periodo').show();
                        $('#ContentPlaceHolder1_Btn_Guardar_Periodo').hide();
                    }
                 });

                 $(document).on("click", ".guardar", function () {
                     $('#ContentPlaceHolder1_Btn_Modificar_Periodo').hide();
                     $('#ContentPlaceHolder1_Btn_Guardar_Periodo').show();
                 });
             });

             function eliminar(idCriterio_Evaluacion) {

                 var id = $(this).data("id");
                 alert(id);
                 $('#ContentPlaceHolder1_idEliminar').val(id)
             }

             function limpiar() {
                 $('#ContentPlaceHolder1_txt_NombrePeriodo').val("");
                 $('#ContentPlaceHolder1_txt_FechaIn').val("");
                 $('#ContentPlaceHolder1_txt_FechaFi').val("");
             }


</script>

                <div class="row">

                                                    <asp:ScriptManager ID="ScriptManager1" runat="server">
                                </asp:ScriptManager>
&nbsp;<asp:Timer ID="Timer1" runat="server">
                                </asp:Timer>
                <!-- /. ROW  -->
                    <% ED_Nivelacion.Negocios.Periodo_C _objPeriodo_C = new ED_Nivelacion.Negocios.Periodo_C(); %>
                <div class="row">
                    <div class="col-md-22 col-sm-12 col-xs-12">

                        <div class="panel panel-default">
                            <div class="panel-body">
                        <div class="col-lg-12">

                        <div class="portlet portlet-default">
                            <div class="portlet-heading">
                                <div class="portlet-title">
                                    <h4>Periodo Académico</h4>
                                    
                                </div>
                                <div class="clearfix">
                                    <div class ="portlet-widgets"> 
                                        <a class ="btn btn-success btn-xs guardar" data-toggle ="modal" data-target ="#AgregarPeriodo" onclick="limpiar()"> <i class ="fa fa-plus"> Agregar </i> </a>   
                                    </div>
                                </div>
                            </div>
                            <div class="portlet-body">
                                <div class="table-responsive">
                                    <table id="example-table" class="table table-striped table-bordered table-hover table-green">
                                        <thead>
                                            <tr>
                                                <th>#:</th>
                                                <th>NOMBRE PERIODO:</th>
                                                <th>FECHA DE INICIO:</th>
                                                <th>FECHA DE FINALIZACIÓN:</th>
                                                <th>ACCIONES</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <%foreach (var item in _objPeriodo_C.ObtenerPeriodo())
                                              {
                                                  
                                              %>
                                            <tr class="odd gradeX">
                                                <td><%=item.idPeriodo %></td>
                                                <td><%=item.Nombre_Periodo %></td>
                                                <td><%=item.Fecha_Inicio %></td>
                                                <td><%=item.Fecha_Fin %></td>
                                                <td class="center"> <a class ="btn btn-orange btn-sm editar" data-toggle ="modal" data-target ="#AgregarPeriodo" data-id="<%=item.idPeriodo%>" data-nombre="<%=item.Nombre_Periodo%>" data-fechain="<%=item.Fecha_Inicio%>" data-fechafin="<%=item.Fecha_Fin%>"><i class ="fa fa-pencil"></i>MODIFICAR</a>
                                               </td>
                                            </tr>
                                            <%} %>
                                        </tbody>
                                        <asp:TextBox ID="idEliminar" runat="server" CssClass="hidden"></asp:TextBox>
                                    </table>
                                </div>
                                <!-- /.table-responsive -->
                            </div>
                            <!-- /.portlet-body -->
                        </div>
                        <!-- /.portlet -->

                    </div>
                    </div>
                </div>
                <!-- /. ROW  -->
				
            </div>
            <!-- /. PAGE INNER  -->
        </div>
        <!-- /. PAGE WRAPPER  -->
                </div>

        <div class="col-lg-22">
    <div class="modal modal-flex fade" id="AgregarPeriodo" tabindex="-1" role="dialog" aria-labelledby="flexModalLabel" aria-hidden="true">
                                    <div class="modal-dialog">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                                <h4 class="modal-title" id="flexModalLabel">Agregar Periodo Académico</h4>
                                            </div>
                                            <div id="Div1" class="modal-body" runat="server">
                                                <div class="panel panel-default">
 
                            <div class="panel-body">
                               <table class="table table-striped table-bordered table-hover">
                                   <asp:TextBox ID="txt_Editar" runat="server" CssClass="hidden"></asp:TextBox>
                                        <thead>
                                            
                                        </thead>
                                        <tbody>
                                            <tr>
                                                <td class="auto-style2">Nombre Periodo:</td>
                                                <td class="auto-style15">
                                                     &nbsp;<asp:TextBox ID="txt_NombrePeriodo" required runat="server"></asp:TextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="auto-style2">Fecha de Inicio Periodo:</td>
                                                <td class="auto-style15">
                                                    <asp:TextBox ID="txt_FechaIn" type="date" runat="server" OnTextChanged="txt_FechaIn_TextChanged"></asp:TextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="auto-style4">Fecha de Final de Periodo:</td>
                                                <td class="auto-style5">
                                                    <asp:TextBox ID="txt_FechaFi" type="date" runat="server"></asp:TextBox>
                                                </td>
                                            </tr>

                                        </tbody>
                                    </table> 
                            </div>
                        </div>
                                            </div>
                                            <div class="modal-footer">
                                    <asp:Button ID="Btn_Guardar_Periodo" runat="server" cssClass="btn btn-default btn-sm" Text="GUARDAR" OnClick="Btn_Guardar_Periodo_Click" />
                                                <asp:Button ID="Btn_Modificar_Periodo" runat="server" cssClass="btn btn-default btn-sm" Text="EDITAR" OnClick="Btn_Modificar_Periodo_Click"  />

                                            </div>
                                        </div>
                                        <!-- /.modal-content -->
                                    </div>
                                    <!-- /.modal-dialog -->
                                </div>
                                <!-- /.modal --> 
               </div>

                        <script>
                           

                            $('[data-id]').click(function () {
                                var Id = $(this).data('id');
                                $("#ContentPlaceHolder1_idEliminar").val(Id);
                                //alert(Id);
                            });
                            $('[data-toggle="confirmation"]').confirmation({
                                placement: 'top', // How to position the confirmation - top | bottom | left | right
                                trigger: 'click', // How confirmation is triggered - click | hover | focus | manual
                                title: 'Esta seguro?', // Default title value if `data-title` attribute isn't present  
                                template: '<div class="popover" >' +
                                    '<div class="arrow"></div>' +
                                    '<h3 class="popover-title"></h3>' +
                                    '<div class="popover-content text-center">' +
                                    '<div id="botones" class="btn-group">' +
                                    '<asp:LinkButton ID="BtnEliminar" runat="server" CssClass="btn btn-success btn-xs" OnClick="Delete_Click"><i class="fa fa-check-circle icon-white"></i> Si</asp:LinkButton>' +
                                    '<a class="btn btn-xs" data-dismiss="confirmation"></a>' +
                                    '</div>' +
                                    '</div>'
                                , btnOkClass: 'btn-primary'
                                , btnOkIcon: 'fa fa-check-circle'
                                , btnCancelClass: 'btn-danger'
                                , btnOkLabel: 'Si'
                                , btnCancelIcon: 'fa fa-times-circle'
                                , btnCancelLabel: 'No',
                                singleton: true, // Set true to allow only one confirmation to show at a time.
                                popout: false, // Set true to hide the confirmation when user clicks outside of it.
                                onConfirm: function () {

                                }, // Set event when click at confirm button
                                onCancel: function () { }
                            }); // Set event when click at cancel button
                    </script>
         </form>
</asp:Content>
